package com.alexgaoyh.MutiModule.Dubbo.RWSeperate.provider.read.manager.sysman.sysmanResource;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.MutiModule.common.myPage.MyPageView;
import com.MutiModule.common.myPage.util.MyPageViewUtilss;
import com.MutiModule.common.vo.TreeNode;
import com.MutiModule.common.vo.mybatis.pagination.Page;
import com.alexgaoyh.MutiModule.Dubbo.RWSeperate.api.manager.sysman.sysmanResource.read.ISysmanResourceReadService;
import com.alexgaoyh.MutiModule.Dubbo.RWSeperate.persist.manager.sysman.sysmanResource.SysmanResource;
import com.alexgaoyh.MutiModule.Dubbo.RWSeperate.persist.manager.sysman.sysmanResource.SysmanResourceExample;
import com.alexgaoyh.MutiModule.Dubbo.RWSeperate.persist.manager.sysman.sysmanResource.SysmanResourceMapper;

@Service(value = "sysmanResourceService")
public class SysmanResourceServiceImpl implements ISysmanResourceReadService{
	
	@Resource(name = "sysmanResourceMapper")
	private SysmanResourceMapper mapper;

	@Override
	public int countByExample(SysmanResourceExample example) {
		return mapper.countByExample(example);
	}

	@Override
	public List<SysmanResource> selectByExample(SysmanResourceExample example) {
		return mapper.selectByExample(example);
	}

	@Override
	public SysmanResource selectByPrimaryKey(Long id) {
		return mapper.selectByPrimaryKey(id);
	}
	
	@Override
	public MyPageView<SysmanResource> generateMyPageViewVO(SysmanResourceExample exampleWithOutPage, Page page) {
		
		int _totalCount = mapper.countByExample(exampleWithOutPage);
		
		exampleWithOutPage.setPage(page);
		
		List<SysmanResource> _list = mapper.selectByExample(exampleWithOutPage);
		
		MyPageView<SysmanResource> pageView = new MyPageViewUtilss<SysmanResource>().generaterMyPageView(page.getLength(), page.getPageNo(), _totalCount, _list);
		
		return pageView;
	}
	
	/**
     * 根据资源id，获取treeNode 集合
     * @param id	资源id
     * @return
     */
	@Override
    public List<TreeNode> selectTreeNodeBySysmanResourceId(Long id) {
		return mapper.selectTreeNodeBySysmanResourceId(id);
	}

}
